/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.just.dusin.ooii.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public  class DateUtil {
    public static Date get(int year,int month,int day,int hour,int min,int second){
        Date rtDate=null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");        
        try {
            rtDate = sdf.parse(""+year+"-"+month+"-"+day+"-"+hour+"-"+min+"-"+second);
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
        return rtDate;
    }
    
    public static String get(Date time,String pattern){
        String rtString=null;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern); 
        rtString = sdf.format(time);
        return rtString;
    }
    
    //返回当前时间字符串
    public static String get(){
        return get(new Date());
    }
    
    public static String get(Date time){
        String rtString=null;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
        rtString = sdf.format(time);
        return rtString;
    }
    
    public static Date get(String time,String pattern){
        Date rtDate=null;
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            rtDate = sdf.parse(time);
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
        return rtDate;
    }
    
    public static Date get(String time){
        return get(time,"yyyy-MM-dd HH:mm");
    }
    
    public static String getString(int year,int month,int day,int hour,int min,int second){
        return ""+year+"-"+month+"-"+day+" "+hour+":"+min+":"+second;
    }
}
